package test

import org.apache.spark.sql.functions.udf
import org.apache.spark.sql.types._
import org.apache.spark.sql.{Row, SparkSession}
import org.apache.spark.{SparkConf, SparkContext}

import scala.collection.mutable

/**
  * Created by liuwei on 2017/7/7.
  */
object TestReg {

  def main(args: Array[String]): Unit = {
   var s = "abc12法ht//www.ba  idu.comliuwei@123.com"
    var s2 = "杭州紫8616500001234"
    var a = ".*[a-zA-Z].*"//英文出现至少一次
    var b = ".*\\d+.*"//数字出现至少一次
    val c = ".*[\\u4e00-\\u9fa5]+.*"//
    val d = ".*(?i)http[s]?://([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*).*"
     val e = ".*[。|.|？|?|！|!|，|,|、|；|;|：|:|“|”|‘|’|\"|'|（|）(|)|【|】|\\[|\\]|［|］|〔|〕|{|}|《|》|〈|〉|…|·|．|~|—|-|－|﹏|～|＿|–].*"
    val f = ".*[\\s*|\\t|\\r|\\n|\\r\\n].*"//
    val g = ".*\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*.*"//
    val h =".*(13[0-9]|14[5|7|9]|15[0|1|2|3|5|6|7|8|9]|17[0|1|3|5|6|7|8]|18[0|1|2|3|5|6|7|8|9])(\\u0020|\\u002d)?[0-9][0-9][0-9][0-9](\\u0020|\\u002d)?[0-9][0-9][0-9][0-9].*"

    val matches = s.matches(a)

    println(matches)

//    println(HasDigit(s))
  }


  def isByRegex(s : String,patt :String) = {
    val pattern = patt.r
    println(pattern)


    s match {
      case pattern(_*) => true
      case _ => false
    }
  }


  import java.util.regex.Pattern

  def HasDigit(content: String): Boolean = {
    var flag = false
    val p = Pattern.compile(".*\\d+.*")
    val m = p.matcher(content)
    if (m.matches) flag = true
    flag
  }

}
